Matrix Multiplication

Introduction

Matrix multiplication is a way to combine two transformations into a single transformation.
If you already know how a matrix acts on a vector—turning $v$ into $Av$—then matrix multiplication tells you how to apply two such actions in a row using one new matrix.

This idea is powerful because it lets us:

Why Combine Transformations?

Some common reasons:

Instead of computing each step separately, we can build one matrix that does everything at once.

Matrix Multiplication as “Do This, Then That”

Suppose:

If you apply $A$ then $B$ to a vector $v$, you compute: $$B(Av)$$ Matrix multiplication defines a new matrix $C$ such that: $$C v = B(Av)$$ So the combined matrix is: $$C = BA$$ Important:
The order is right-to-left because the vector is on the right.

How Matrix Multiplication Works

To multiply two matrices:

For example, if $$A = \begin{pmatrix} a & b \\ c & d \end{pmatrix}, \quad B = \begin{pmatrix} p & q \\ r & s \end{pmatrix}$$ Then: $$BA = \begin{pmatrix} pa + qc & pb + qd \\ ra + sc & rb + sd \end{pmatrix}$$ You don’t need to memorize this—just remember:

Geometric Meaning

Matrix multiplication corresponds to doing one geometric action after another.

Examples:

Each combined action is still linear, so it can be represented by a single matrix.

Common Mistakes

Calculator

Multiplying matrices

  • Matrices can be multiplied in the same way as any other data type:
[1, 2; 0, 1] * [3, 0; 1, 4] multiply([1, 0; 0, 1], [3, -2; 1, 1])

Exercises

  1. Multiply the matrices $$\begin{pmatrix}1 & 2 \\ 0 & 1\end{pmatrix} \begin{pmatrix}3 & 0 \\ 1 & 4\end{pmatrix}$$

    Solution

    $$\begin{pmatrix}1 & 2 \\ 0 & 1\end{pmatrix} \begin{pmatrix}3 & 0 \\ 1 & 4\end{pmatrix} = \begin{pmatrix} 1\cdot 3 + 2\cdot 1 & 1\cdot 0 + 2\cdot 4 \\ 0\cdot 3 + 1\cdot 1 & 0\cdot 0 + 1\cdot 4 \end{pmatrix} = \begin{pmatrix}5 & 8 \\ 1 & 4\end{pmatrix}$$
  2. Compute the product $$\begin{pmatrix}2 & 1 \\ 1 & 0\end{pmatrix} \begin{pmatrix}4 \\ 3\end{pmatrix}$$

    Solution

    $$\begin{pmatrix}2 & 1 \\ 1 & 0\end{pmatrix} \begin{pmatrix}4 \\ 3\end{pmatrix} = \begin{pmatrix}2\cdot 4 + 1\cdot 3 \\ 1\cdot 4 + 0\cdot 3\end{pmatrix} = \begin{pmatrix}11 \\ 4\end{pmatrix}$$
  3. Let $A$ be a rotation matrix and $B$ be a scaling matrix.
    Explain in words what the matrix $BA$ represents.

    Solution


    $BA$ means “rotate, then scale.”
    The combined matrix performs both actions in that order.
  4. Determine whether the product $AB$ is defined if
    $A$ is $2 \times 3$ and $B$ is $3 \times 2$.

    Solution


    Yes, $AB$ is defined because the inner dimensions match ($3=3$).
    The result is a $2 \times 2$ matrix.
  5. tranform the vector by the matrix $$\begin{pmatrix}0 & 1 \\ 1 & 0\end{pmatrix} \begin{pmatrix}5 \\ 7\end{pmatrix}$$

    Solution

    $$\begin{pmatrix}0 & 1 \\ 1 & 0\end{pmatrix} \begin{pmatrix}5 \\ 7\end{pmatrix} = \begin{pmatrix}7 \\ 5\end{pmatrix}$$ This matrix swaps the two entries.
  6. True or false: If $AB$ is defined, then $BA$ is always defined.

    Solution


    False.
    Even if $AB$ is defined, $BA$ may not be.
  7. Compute $$\begin{pmatrix}3 & -1 \\ 2 & 4\end{pmatrix} \begin{pmatrix}1 & 0 \\ 0 & 2\end{pmatrix}$$

    Solution

    $$\begin{pmatrix}3 & -1 \\ 2 & 4\end{pmatrix} \begin{pmatrix}1 & 0 \\ 0 & 2\end{pmatrix} = \begin{pmatrix} 3\cdot 1 + (-1)\cdot 0 & 3\cdot 0 + (-1)\cdot 2 \\ 2\cdot 1 + 4\cdot 0 & 2\cdot 0 + 4\cdot 2 \end{pmatrix} = \begin{pmatrix}3 & -2 \\ 2 & 8\end{pmatrix}$$